package com.fr.report.highlight;

import com.fr.base.FCloneable;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.CellElement;
import com.fr.report.io.xml.ReportXMLUtils;
import com.fr.report.script.Calculator;
import java.util.ArrayList;
import java.util.List;

public class DefaultHighlight extends AbstractHighlight
{
  private List highlightActionList = new ArrayList();

  public void addHighlightAction(HighlightAction paramHighlightAction)
  {
    this.highlightActionList.add(paramHighlightAction);
  }

  public int actionCount()
  {
    return this.highlightActionList.size();
  }

  public HighlightAction getHighlightAction(int paramInt)
  {
    return ((HighlightAction)this.highlightActionList.get(paramInt));
  }

  public void removeActions()
  {
    this.highlightActionList.clear();
  }

  public void action(CellElement paramCellElement, Calculator paramCalculator)
  {
    int i = 0;
    int j = this.highlightActionList.size();
    while (i < j)
    {
      getHighlightAction(i).action(paramCellElement, paramCalculator);
      ++i;
    }
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    DefaultHighlight localDefaultHighlight = (DefaultHighlight)super.clone();
    ArrayList localArrayList = new ArrayList();
    int i = 0;
    int j = actionCount();
    while (i < j)
    {
      localArrayList.add(getHighlightAction(i).clone());
      ++i;
    }
    localDefaultHighlight.highlightActionList = localArrayList;
    return localDefaultHighlight;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if ((paramXMLableReader.isChildNode()) && ("HighlightAction".equals(paramXMLableReader.getTagName())))
    {
      HighlightAction localHighlightAction = ReportXMLUtils.readHighlightAction(paramXMLableReader);
      if (localHighlightAction != null)
        addHighlightAction(localHighlightAction);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    int i = 0;
    int j = actionCount();
    while (i < j)
    {
      HighlightAction localHighlightAction = getHighlightAction(i);
      paramXMLPrintWriter.startTAG("HighlightAction").attr("class", localHighlightAction.getClass().getName());
      localHighlightAction.writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
      ++i;
    }
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof DefaultHighlight))
      return false;
    DefaultHighlight localDefaultHighlight = (DefaultHighlight)paramObject;
    if (actionCount() != localDefaultHighlight.actionCount())
      return false;
    int i = 0;
    int j = actionCount();
    while (i < j)
    {
      if (!(getHighlightAction(i).equals(localDefaultHighlight.getHighlightAction(i))))
        return false;
      ++i;
    }
    return true;
  }
}